﻿
#region Usings
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
//using Xceed.Wpf;
//using wpfToolkit = Xceed.Wpf.Toolkit;
#endregion

namespace FasterWPF
{
    public static partial class CommonExt
    {
        #region Other

        /// <summary>
        /// Show Grid Lines on the Composite's Grid
        /// </summary>
        /// <typeparam name="Grid"></typeparam>
        /// <param name="chain"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public static ContentControl ShowGridLinesOnGridComposite<Grid>(this ContentControl chain, Grid source)
            where Grid : System.Windows.Controls.Grid
        {
            IComposite icomp = SettingsManager.GetIComposite<Grid>(source);
            (icomp as GridComposite).ShowGridLines(chain);

            return chain;
        }

        public static InnerChain<T> AddCustomTabItem<T>(this InnerChain<T> chain, int row, int col, ContentControl header, TabItem body)
    where T : FrameworkElement
        {
            chain.Item3.Add(((container) =>
            {
                return container.AddCustomTabItem<T>(chain.Item2, row, col, header, body);
            }));
            return chain;
        }

        public static ContentControl AddCustomTabItem<T>(this ContentControl chain, string key, int row, int col, ContentControl header, TabItem body)
     where T : FrameworkElement
        {
            CustomTabItem cTabItem = new CustomTabItem(header, body);
            // body.Header = header;

            T lbx = ((ContentControl)chain).GetParentFromContentControlOfComposite<T>();
            Dictionary<string, object> settings = lbx.GetSettingsDictionary();
            string row_col = row + "_" + col;
            string fullKey = key + "_" + row_col;

            addCommon<TabItem, T>(chain, row, col, lbx, settings, fullKey, cTabItem);
            return chain;
        }

        #endregion

    }//end of class
}//end of namespace
